Repository navigation
Conversation
mjanthony819
left a comment
There was a problem hiding this comment.
Nice regression net. The four addresses pin both edges of 172.16.0.0/12 against the prefix regex in _check_private_ip, and exercising cidr=True/False covers both the IPv4Network and IPv4Address paths. I ran the new cases on top of 22786cc: all 8 pass.
One additive suggestion: the same four addresses with private left at its default (None) currently all validate, because the filter is skipped entirely. That default path is what most callers rely on, and a regression that started applying the filter by default would slip past these tests. Pinning it is cheap:
@pytest.mark.parametrize(
"address",
["172.15.255.255", "172.16.0.0", "172.31.255.255", "172.32.0.0"],
)
def test_ipv4_private_172_range_default_unfiltered(address: str):
"""Test the default (no private filter) accepts both edges of 172.16.0.0/12."""
assert ipv4(address, cidr=True) is True
assert ipv4(address, cidr=False) is TrueVerified locally that all four return True today under the default. Not blocking, just an extra invariant while the boundaries are being pinned.
AI assistance covered the analysis and this review text.
Related to #564.
I could not reproduce the reported classification bug on master at 22786cc. This test-only change covers both endpoints of 172.16.0.0/12 and the immediately adjacent addresses. It checks both private filters with CIDR enabled and disabled to catch regressions that narrow or widen the private range. The implementation is unchanged.
Validation:
git diff --checkpassed.Developed and validated with assistance from OpenAI Codex.